<?php
/**
 * Created by PhpStorm.
 * User: 仙女大人
 * Date: 2019/6/17
 * Time: 20:25
 */

namespace app\admin\model;
use think\Model;

class rules extends Model
{
    // 设置数据表（不含前缀）
    protected $name = 'auth_rule';

    public function getRules($array, $pid ,$s=''){
        //dump($array);
        $data =array();
        foreach ($array as $k => $v){
            if($v['pid'] == $pid){
                $v['s'] = $s;
                $data[] = $v;
                $child = $this->getRules($array,$v["id"],$s.'&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp');
                foreach ($child as $val){
                    $data[] = $val;
                }
            }
        }
        return $data;
    }
}